<script src="../include.js"></script>
<script>
    asyncTest(done => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);

        iframe.contentWindow.addEventListener("beforeunload", e => {
            println("Before unload event fired");
            e.preventDefault();
            println(`Default prevented: ${e.defaultPrevented}`);
        });

        iframe.addEventListener("load", e => {
            println(`iframe load: ${e.target.src}`);
            done();
        });

        iframe.src = "about:blank";
    });
</script>
